<%--
  Created by IntelliJ IDEA.
  author: Jsonor
  date: 2018/3/20 16:40
  description: Description
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
      integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<html>
<head>
    <title>展示国家列表</title>
</head>
<body>


<h1 align="center">国家信息大全</h1>
<table align="center" style="background-color: aqua" class="table-bordered">
    <div style="text-align: center">
        <form action="${pageContext.request.contextPath}/app/searchCountry">
            <input type="text" name="name" value="">
            <input type="submit" value="搜索">
        </form>
        <hr>
        <a href="${pageContext.request.contextPath}/app/sendAddMessage" style="text-decoration: none">增添国家信息</a>
    </div>

    <tr>
        <td>ID</td>
        <td>Code</td>
        <td>Name</td>
        <td>Region</td>
        <td>SurfaceArea</td>
        <td>IndepYear</td>
        <td>Population</td>
        <td>LifeExpectancy</td>
        <td>GNP</td>
        <td>HeadOfState</td>
        <td>Capital</td>
        <td>Code2</td>
        <td>Function</td>
    </tr>
    <c:forEach items="${page.pageList}" var="c" varStatus="status">
        <tr>
            <td>${status.count}</td>
            <td>${c.code}</td>
            <td>${c.name}</td>
            <td>${c.region}</td>
            <td>${c.surfaceArea}</td>
            <td>${c.indepYear}</td>
            <td>${c.population}</td>
            <td>${c.lifeExpectancy}</td>
            <td>${c.gNP}</td>
            <td>${c.headOfState}</td>
            <td>${c.capital}</td>
            <td>${c.code2}</td>
            <td>
                <a href="${pageContext.request.contextPath}/app/showCountryMessage?cname=${c.name}"
                   style="text-decoration: none">修改</a>|
                <a href="${pageContext.request.contextPath}/app/deleteCountry?cname=${c.name}"
                   onclick="return confirm('确定要删除吗？')" style="text-decoration: none">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>


<%--分页查询栏--%>
<table>
    <div align="center">
        第${page.currentPage}页/共${page.pageCount}页
        <hr>
        <c:if test="${page.currentPage>1}">
            <a href="${pageContext.request.contextPath}/app/pageBean?currentPage=${page.currentPage-1}">上一页</a>
        </c:if>
        <c:forEach var="num" begin="1" end="${page.pageCount}">
            <c:choose>
                <c:when test="${num==page.currentPage}">
                    ${num}
                </c:when>
                <c:otherwise>
                    <a href="${pageContext.request.contextPath}/app/pageBean?currentPage=${num}">[${num}]</a>
                </c:otherwise>
            </c:choose>
        </c:forEach>
        <c:if test="${page.currentPage<page.pageCount}">
            <a href="${pageContext.request.contextPath}/app/pageBean?currentPage=${page.currentPage+1}">下一页</a>
        </c:if>
        <hr>
        <a href="${pageContext.request.contextPath}/app/pageBean?currentPage=1">首页</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
        <a href="${pageContext.request.contextPath}/app/pageBean?currentPage=${page.pageCount}">尾页</a>
    </div>
</table>

</body>
</html>